////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017-2018 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// THIS IS AUTO-GENERATED CODE.  PLEASE DO NOT EDIT (File bug reports against tools).
///
/// Auto-generated by: ParameterParser V1.1.4
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  camxsensorcommon.cpp
/// @brief Auto-generated Chromatix parameter file
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "camxsensorcommon.h"
#include "parametersetmanager.h"

CAMX_NAMESPACE_BEGIN


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load RegisterSetting
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL camxsensorcommonClass::LoadRegisterSetting(
    ParameterFileSymbolTableEntry* entry,
    RegisterSetting* structure)
{
    BOOL result = TRUE;

    // Reading structure->slaveAddr from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->slaveAddrExists);
        structure->slaveAddrID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->slaveAddrExists)
        {
            result = result && pointerEntry1->ReadUInt16(&structure->slaveAddr);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->slaveAddr);
        }
    }
    result = result && entry->ReadUInt32(&structure->registerAddr);

    // Reading structure->registerData from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->registerDataCount);
        structure->registerDataID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->registerData   = PARAMETER_NEW RegisterData[structure->registerDataCount];
            result = result && structure->registerData != NULL;
        }
        if (!result || structure->registerData == NULL)
        {
            structure->registerDataCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->registerDataCount; i++)
        {
            result = result && pointerEntry1->ReadUInt32(&structure->registerData[i]);
        }
    }
    result = result && entry->ReadUInt32(&structure->regAddrType);
    result = result && entry->ReadUInt32(&structure->regDataType);
    structure->operation = (OperationType)entry->ReadEnum(&result);

    // Reading structure->delayUs from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->delayUsExists);
        structure->delayUsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->delayUsExists)
        {
            result = result && pointerEntry1->ReadUInt32(&structure->delayUs);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->delayUs);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load SettingsInfo
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL camxsensorcommonClass::LoadSettingsInfo(
    ParameterFileSymbolTableEntry* entry,
    SettingsInfo* structure)
{
    BOOL result = TRUE;

    // Reading structure->regSetting from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->regSettingCount);
        structure->regSettingID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->regSetting   = PARAMETER_NEW RegisterSetting[structure->regSettingCount];
        }
        if (!result || structure->regSetting == NULL)
        {
            structure->regSettingCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->regSettingCount; i++)
        {
            result = result && LoadRegisterSetting(pointerEntry1, &structure->regSetting[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load PowerSetting
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL camxsensorcommonClass::LoadPowerSetting(
    ParameterFileSymbolTableEntry* entry,
    PowerSetting* structure)
{
    BOOL result = TRUE;
    structure->configType = (PowerConfigurationType)entry->ReadEnum(&result);
    result = result && entry->ReadUInt32(&structure->configValue);
    result = result && entry->ReadUInt32(&structure->delayMs);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load PowerSequenceInfo
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL camxsensorcommonClass::LoadPowerSequenceInfo(
    ParameterFileSymbolTableEntry* entry,
    PowerSequenceInfo* structure)
{
    BOOL result = TRUE;

    // Reading structure->powerSetting from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->powerSettingCount);
        structure->powerSettingID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->powerSetting   = PARAMETER_NEW PowerSetting[structure->powerSettingCount];
        }
        if (!result || structure->powerSetting == NULL)
        {
            structure->powerSettingCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->powerSettingCount; i++)
        {
            result = result && LoadPowerSetting(pointerEntry1, &structure->powerSetting[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load FrameDimension
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL camxsensorcommonClass::LoadFrameDimension(
    ParameterFileSymbolTableEntry* entry,
    FrameDimension* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->xStart);
    result = result && entry->ReadUInt32(&structure->yStart);
    result = result && entry->ReadUInt32(&structure->width);
    result = result && entry->ReadUInt32(&structure->height);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load Dimension
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL camxsensorcommonClass::LoadDimension(
    ParameterFileSymbolTableEntry* entry,
    Dimension* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->width);
    result = result && entry->ReadUInt32(&structure->height);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load Position
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL camxsensorcommonClass::LoadPosition(
    ParameterFileSymbolTableEntry* entry,
    Position* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->x);
    result = result && entry->ReadUInt32(&structure->y);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload RegisterSetting
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void camxsensorcommonClass::UnloadRegisterSetting(
    RegisterSetting* structure)
{
    PARAMETER_DELETE[] structure->registerData;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload SettingsInfo
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void camxsensorcommonClass::UnloadSettingsInfo(
    SettingsInfo* structure)
{
    for (UINT32 i = 0; i < structure->regSettingCount; i++)
    {
        UnloadRegisterSetting(&structure->regSetting[i]);
    }
    PARAMETER_DELETE[] structure->regSetting;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload PowerSequenceInfo
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void camxsensorcommonClass::UnloadPowerSequenceInfo(
    PowerSequenceInfo* structure)
{
    PARAMETER_DELETE[] structure->powerSetting;
}

CAMX_NAMESPACE_END
